package com.leyou.service;

import com.leyou.dao.CategoryMapper;
import com.leyou.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {

    @Autowired
    CategoryMapper categoryMapper;

    public List<Category> queryCategoriesByPid(Integer pid){
        Category record = new Category();
        record.setParentId(pid);
        return categoryMapper.select(record);
    }

    public int deleteById(Integer id) {
        int i = categoryMapper.deleteByPrimaryKey(id);
        return i;
    }

    public int updateCategory(Category category) {
        int i = categoryMapper.updateByPrimaryKeySelective(category);
        return i;
    }

    public int addCategory(Category category) {
        int insert = categoryMapper.insert(category);
        return insert;
    }

    public Category findCategoryById(Integer cid) {
        Category category=  categoryMapper.findCategoryById(cid);
        return category;
    }

    public List<Category> findCategoryByCids(Integer cid1, Integer cid2, Integer cid3) {
        List<Category>  list=  categoryMapper.findCategoryByCids(cid1,cid2,cid3);
        return list;
    }
}
